<template>
  <div class="home-container">
    <div v-if="!isShow" class="skeleton">
      <img src="@/assets/img/skeleton.jpg" alt="">
    </div>
    <template v-else>
      <Header />
      <sowing :sowing-list="list" />
      <toolbar />
      <g-divider :height="5" class="g-divider" />
      <g-ad :src="ad" />
      <div class="tob-bar">
        <div v-waves class="item">
          <img src="@/assets/img/index/1.png" alt="" class="item">
        </div>
        <div v-waves class="item">
          <img src="@/assets/img/index/2.png" alt="" class="item">
        </div>
      </div>
      <div class="tob-bar">
        <div v-waves class="item">
          <img src="@/assets/img/index/3.png" alt="" class="item">
        </div>
        <div v-waves class="item">
          <img src="@/assets/img/index/4.png" alt="" class="item">
        </div>
      </div>
      <g-title title="热门资讯" line class="tit" font-color="#EB2415" />
      <router-link v-for="item in newList" :key="item.id" :to="{path: 'articleDetail/3'}" tag="div">
        <g-list
          double
          :src="item.avatar"
          :title="item.title"
          :date="item.date"
          :ping="item.ping"
          :zan="item.zan"
        />
      </router-link>
    </template>
    <transition name="loading">
      <loading v-show="showLoading" />
    </transition>
  </div>
</template>

<script>
import Header from './components/header'
import sowing from './components/sowing'
import toolbar from './components/toolbar'
import waves from '@/directive/waves/index.js' // use waves by v-directive
import api from '@/api'
import loading from '@/components/loading'
export default {
  components: {
    sowing,
    Header,
    toolbar,
    loading
  },
  directives: {
    waves
  },
  data() {
    return {
      showLoading: true,
      isShow: false,
      list: [
        {
          cid: 1030,
          public_id: '5d417cc54df3e3c4738de681',
          public_name: '七夕美食告白190801',
          meteria_id: '5d417c774df3e37d378de40a',
          icon_url: 'https://img.ddimg.mobi/94c44f8c4e9611564572820049.jpg',
          link: {
            type: 0,
            data: {
              url:
                'https://maicai.m.ddxq.mobi/?v=1.0#/activity/special?page_id=5d4104274fb7977a528c57eb'
            }
          },
          is_pop_login: 0
        },
        {
          cid: 1031,
          public_id: '5d406f3c4ed5bdc23d8cf4ac',
          public_name: '嗨吃一夏鸡任选2件_轮播190803',
          meteria_id: '5d406eea4df3e3df3f8d0d93',
          icon_url: 'https://img.ddimg.mobi/d2c94e1f7d5381564503773709.jpg',
          link: {
            type: 0,
            data: {
              url:
                'https://maicai.m.ddxq.mobi/?v=1.0#/activity/special?page_id=5d406b034ed5bd78458cd3a3'
            }
          },
          is_pop_login: 0
        },
        {
          cid: 1032,
          public_id: '5d4426564fb797a17c8e3e06',
          public_name: '一口下去降5℃',
          meteria_id: '5d4425734df3e345028cc798',
          icon_url: 'https://img.ddimg.mobi/0f7426803397d1564747121080.jpg',
          link: {
            type: 0,
            data: {
              url:
                'https://maicai.m.ddxq.mobi/?v=1.0#/activity/special?page_id=5d4422604df3e3f3668b91e8'
            }
          },
          is_pop_login: 0
        },
        {
          cid: 1034,
          public_id: '5d3d4ccb4fb797997e8e73dd',
          public_name: '美食图鉴轮播7.28',
          meteria_id: '5d3d4c874df3e382488ef07c',
          icon_url: 'https://img.ddimg.mobi/7c2df4a57cb251564298372619.jpg',
          link: {
            type: 0,
            data: {
              url:
                'https://maicai.m.ddxq.mobi/?v=1.0#/activity/special?page_id=5d3d495c4df3e30c498efc2f'
            }
          },
          is_pop_login: 0
        },
        {
          cid: 1035,
          public_id: '5d43f6b34ed5bd39548edcc9',
          public_name: '早餐轮播8.3',
          meteria_id: '5d3e58614ed5bd181e8f5f51',
          icon_url: 'https://img.ddimg.mobi/79d89da5e5a4b1564366938694.jpg',
          link: {
            type: 0,
            data: {
              url:
                'https://maicai.m.ddxq.mobi/?v=1.0#/activity/special?page_id=5d3e57e24df3e3e2488fa16f'
            }
          },
          is_pop_login: 0
        },
        {
          cid: 1037,
          public_id: '5d444fd34df3e3d0578baf4f',
          public_name: '美心月饼预售8.02',
          meteria_id: '5d444f814fb797c0598e665c',
          icon_url: 'https://img.ddimg.mobi/8edae202b398c1564758158788.jpg',
          link: {
            type: 0,
            data: {
              url:
                'https://maicai.m.ddxq.mobi/?v=1.0#/activity/special?page_id=5d4449dd4df3e39d398bb41d'
            }
          },
          is_pop_login: 0
        }
      ],
      newList: [],
      ad:
        'https://imagev2.xmcdn.com/group61/M0A/CD/B2/wKgMZl0W1legiUgkAACPrBBFcJ4381.png'
    }
  },
  created() {
    api.personal.getObj().then(res => {
      this.newList = res.data
    })
    setTimeout(() => {
      this.showLoading = false
      this.isShow = true
    }, 600)
  }
}
</script>

<style></style>

<style lang="scss" scoped>

@keyframes backOpacity{
   0%   { opacity: 1 }
   25%  { opacity: .5 }
   50%  { opacity: 1 }
   75%  { opacity: .5 }
   100% { opacity: 1 }
}

.home-container {
  margin-bottom: 100px;
  .skeleton {
    width: 100%;
    animation: backOpacity 2s ease-in-out infinite;
    img {
      width: 100%;
    }
  }
  .g-divider {
    margin-top: 20px;
  }
  .tob-bar {
    display: flex;
    flex-wrap: wrap;
    padding: 0 6px;
    .item {
      flex: 1;
      img {
        width: 100%;
      }
    }
  }
  .tit {
    border-top: 1px solid $bg;
    border-bottom: 1px solid $bg;
  }
  .list {
    h3 {
      line-height: 24px !important;
    }
    .address,
    .time {
      color: #999999;
      height: 18px;
      line-height: 18px;
      .iconfont {
        font-size: 12px;
      }
    }
  }
}
</style>
